package cuongnh.project.japanesediary.vocabulary.ui.editor.kanji.page.general;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;

import cuongnh.project.japanesediary.vocabulary.common.CommonServices;
import cuongnh.project.japanesediary.vocabulary.model.Kanji;
import cuongnh.project.japanesediary.vocabulary.ui.editor.kanji.page.general.section.KanjiGeneralInfoSection;

public class KanjiGeneralInfoPage extends FormPage {

	private Kanji kanji;
	private CommonServices commonServices;

	/**
	 * Create the form page.
	 * 
	 * @param editor
	 * @param id
	 * @param title
	 * @wbp.parser.constructor
	 * @wbp.eval.method.parameter id "Some id"
	 * @wbp.eval.method.parameter title "Some title"
	 */
	public KanjiGeneralInfoPage(FormEditor editor, String id, String title) {
		super(editor, id, title);
	}

	/**
	 * Create the form page.
	 * 
	 * @param editor
	 * @param id
	 * @param title
	 * @wbp.parser.constructor
	 * @wbp.eval.method.parameter id "Some id"
	 * @wbp.eval.method.parameter title "Some title"
	 */
	public KanjiGeneralInfoPage(FormEditor editor, String id, String title,
			Kanji kanji, CommonServices commonServices) {
		super(editor, id, title);
		this.kanji = kanji;
		this.commonServices = commonServices;
	}

	/**
	 * Create contents of the form.
	 * 
	 * @param managedForm
	 */
	@Override
	protected void createFormContent(IManagedForm managedForm) {
		FormToolkit toolkit = managedForm.getToolkit();
		final ScrolledForm form = managedForm.getForm();
		form.setText("Kanji - General information page");
		Composite body = form.getBody();
		toolkit.decorateFormHeading(form.getForm());
		toolkit.paintBordersFor(body);
		managedForm.getForm().getBody().setLayout(new GridLayout(1, false));

		KanjiGeneralInfoSection kanjiGeneralInfoSection = new KanjiGeneralInfoSection(
				body, toolkit, Section.EXPANDED | Section.TITLE_BAR, kanji,
				commonServices);
		kanjiGeneralInfoSection.getSection().setLayoutData(
				new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		managedForm.addPart(kanjiGeneralInfoSection);
	}

	@Override
	public void doSave(IProgressMonitor monitor) {
		super.doSave(monitor);
	}
}
